package edu.njust.LabSystem.Service;

import edu.njust.LabSystem.dao.IExperiment;
import edu.njust.LabSystem.entity.Experiment;
import edu.njust.LabSystem.entity.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;


public class ExperimentService {

	public Experiment getExperimentById(String id) {

		SqlSession sqlSession=MybatisUtil.getSqlSession();
		
		IExperiment Iexperiment=sqlSession.getMapper(IExperiment.class);
		Experiment experiment=Iexperiment.getExperimentById(id);
				
		sqlSession.close();
		
		return experiment;
	}

	public List<Experiment> getExperimentByClassid(String cid) {
		SqlSession sqlSession=MybatisUtil.getSqlSession();
		
		IExperiment Iexperiment=sqlSession.getMapper(IExperiment.class);
		List<Experiment> experiments=Iexperiment.getExperimentByClassid(cid);
				
		sqlSession.close();
		
		return experiments;
	}
	public List<Experiment> getExperiments() {
		SqlSession sqlSession=MybatisUtil.getSqlSession();
		
		IExperiment Iexperiment=sqlSession.getMapper(IExperiment.class);
		List<Experiment> experiments=Iexperiment.getExperiments();
				
		sqlSession.close();
		
		return experiments;
	}
}
